//
//  CHGrideViewDataSource.swift
//  CHSimpleUI
//
//  Created by cyptt on 2023/3/30.
//

import UIKit

class CHGrideViewDataSource: CHBaseColDataSource ,UICollectionViewDataSource{

    override init(identifier: String, successCallBack: dataColSourceSuccessBlock? = nil) {
        super.init(identifier: identifier,successCallBack: successCallBack)
        
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return self.datas.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell:CHGridViewColCell? = collectionView.dequeueReusableCell(withReuseIdentifier: self.identifier , for: indexPath as IndexPath) as? CHGridViewColCell
        
        if self.successCallBack != nil{
            self.successCallBack!(cell!,self.datas[indexPath.row],indexPath,collectionView)
        }
     
        return cell ?? CHGridViewColCell()
    }
    
    
    
    
}
